package stsj.meddroid;

import java.io.ObjectOutputStream.PutField;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;

public class Settings {

	public static boolean firstGame;
	public static boolean theEnd;
	
	public static boolean soundEnabled = true;
	public static Boolean[] stagesUnlocked;
	public static Boolean[][] roundsUnlocked;
	public static Boolean[][] roundsLose;
	
	public static int[][] ranks;
	public static Boolean[][] unlockedViro;
	public static Preferences prefs;

	public static boolean modeShieldUnlocked;
	public static boolean modeInvisibleUnlocked;
	public static boolean modeBelumTahuUnlocked;
	public static boolean modeImperialUnlocked;	
	
	public static final int SLIME = 0;
	public static final int DURI = 1;
	public static final int GEBUK = 2;
	public static final int PETELUR = 3;
	public static final int BLACK = 4;
	
	public static final int SLIME_GREEN = 0;
	public static final int SLIME_BLUE = 1;
	public static final int SLIME_RED = 2;
	public static final int SLIME_ORANGE = 3;

	public static final int DURI_GREEN = 0;
	public static final int DURI_ORANGE = 1;
	public static final int DURI_VIOLET = 2;

	public static final int GEBUK_GREEN = 0;
	public static final int GEBUK_PINK = 1;
	public static final int GEBUK_RED = 2;

	public static final int PETELUR_BLUE = 0;
	public static final int PETELUR_VIOLET = 1;
	public static final int PETELUR_YELLOW = 2;
	
	public static final int RBJ = 0;
	public static final int SPT = 1;
	public static final int HTN = 2;
	public static final int SMC = 3;
	

	public static void load() {
		prefs = Gdx.app.getPreferences(".Settings");
		if (prefs != null) {
//			 prefs.putBoolean("first",false); // reset
//			
			firstGame = prefs.getBoolean("first");

			if (!firstGame) {
				soundEnabled = true;
				firstGame = true;
				prefs.putBoolean("first", firstGame);
			
				stagesUnlocked = new Boolean[7];
				roundsUnlocked = new Boolean[7][7];
				roundsUnlocked[1] = new Boolean[7];
				roundsUnlocked[2] = new Boolean[7];
				roundsUnlocked[3] = new Boolean[7];
				roundsUnlocked[4] = new Boolean[7];
				roundsUnlocked[5] = new Boolean[7];


				stagesUnlocked[1] = true;
				stagesUnlocked[2] = false;
				stagesUnlocked[3] = false;
				stagesUnlocked[4] = false;
				stagesUnlocked[5] = false;

				roundsUnlocked[1][1] = true;
				roundsUnlocked[1][2] = false;
				roundsUnlocked[1][3] = false;
				roundsUnlocked[1][4] = false;
				roundsUnlocked[1][5] = false;

				roundsUnlocked[2][1] = false;
				roundsUnlocked[2][2] = false;
				roundsUnlocked[2][3] = false;
				roundsUnlocked[2][4] = false;
				roundsUnlocked[2][5] = false;

				roundsUnlocked[3][1] = false;
				roundsUnlocked[3][2] = false;
				roundsUnlocked[3][3] = false;
				roundsUnlocked[3][4] = false;
				roundsUnlocked[3][5] = false;

				roundsUnlocked[4][1] = false;
				roundsUnlocked[4][2] = false;
				roundsUnlocked[4][3] = false;
				roundsUnlocked[4][4] = false;
				roundsUnlocked[4][5] = false;

				roundsUnlocked[5][1] = false;
				roundsUnlocked[5][2] = false;
				roundsUnlocked[5][3] = false;
				roundsUnlocked[5][4] = false;
				roundsUnlocked[5][5] = false;
				
				modeBelumTahuUnlocked = false;
				modeImperialUnlocked = false;
				modeInvisibleUnlocked = false;
				modeShieldUnlocked= false;
				

				ranks = new int[7][7];
				ranks[1] = new int[7];
				ranks[2] = new int[7];
				ranks[3] = new int[7];
				ranks[4] = new int[7];
				ranks[5] = new int[7];

				ranks[1][1] = 0;
				ranks[1][2] = 0;
				ranks[1][3] = 0;
				ranks[1][4] = 0;
				ranks[1][5] = 0;

				ranks[2][1] = 0;
				ranks[2][2] = 0;
				ranks[2][3] = 0;
				ranks[2][4] = 0;
				ranks[2][5] = 0;

				ranks[3][1] = 0;
				ranks[3][2] = 0;
				ranks[3][3] = 0;
				ranks[3][4] = 0;
				ranks[3][5] = 0;

				ranks[4][1] = 0;
				ranks[4][2] = 0;
				ranks[4][3] = 0;
				ranks[4][4] = 0;
				ranks[4][5] = 0;

				ranks[5][1] = 0;
				ranks[5][2] = 0;
				ranks[5][3] = 0;
				ranks[5][4] = 0;
				ranks[5][5] = 0;

				unlockedViro = new Boolean[7][7];
				unlockedViro[SLIME] = new Boolean[7];
				unlockedViro[DURI] = new Boolean[7];
				unlockedViro[GEBUK] = new Boolean[7];
				unlockedViro[PETELUR] = new Boolean[7];
				unlockedViro[BLACK] = new Boolean[7];
				
				unlockedViro[SLIME][SLIME_GREEN] = false;
				unlockedViro[SLIME][SLIME_BLUE] = false;
				unlockedViro[SLIME][SLIME_ORANGE] = false;
				unlockedViro[SLIME][SLIME_RED] = false;

				unlockedViro[DURI][DURI_GREEN] = false;
				unlockedViro[DURI][DURI_VIOLET] = false;
				unlockedViro[DURI][DURI_ORANGE] = false;

				unlockedViro[GEBUK][GEBUK_GREEN] = false;
				unlockedViro[GEBUK][GEBUK_PINK] = false;
				unlockedViro[GEBUK][GEBUK_RED] = false;

				unlockedViro[PETELUR][PETELUR_BLUE] = false;
				unlockedViro[PETELUR][PETELUR_VIOLET] = false;
				unlockedViro[PETELUR][PETELUR_YELLOW] = false;
				
				unlockedViro[BLACK][RBJ] = false;
				unlockedViro[BLACK][SPT] = false;
				unlockedViro[BLACK][HTN] = false;
				unlockedViro[BLACK][SMC] = false;
				
				theEnd = false;
				

				prefs.putBoolean("theend", theEnd);
				
				prefs.putBoolean("modeShield", modeShieldUnlocked);
				prefs.putBoolean("modeInvis", modeInvisibleUnlocked);
				prefs.putBoolean("modeImperial", modeImperialUnlocked);
				prefs.putBoolean("modeBelumtahu", modeBelumTahuUnlocked);
				
				
				prefs.putBoolean("stage01", stagesUnlocked[1]);
				prefs.putBoolean("stage02", stagesUnlocked[2]);
				prefs.putBoolean("stage03", stagesUnlocked[3]);
				prefs.putBoolean("stage04", stagesUnlocked[4]);
				prefs.putBoolean("stage05", stagesUnlocked[5]);

				prefs.putBoolean("round01-01", roundsUnlocked[1][1]);
				prefs.putBoolean("round01-02", roundsUnlocked[1][2]);
				prefs.putBoolean("round01-03", roundsUnlocked[1][3]);
				prefs.putBoolean("round01-04", roundsUnlocked[1][4]);
				prefs.putBoolean("round01-05", roundsUnlocked[1][5]);

				prefs.putBoolean("round02-01", roundsUnlocked[2][1]);
				prefs.putBoolean("round02-02", roundsUnlocked[2][2]);
				prefs.putBoolean("round02-03", roundsUnlocked[2][3]);
				prefs.putBoolean("round02-04", roundsUnlocked[2][4]);
				prefs.putBoolean("round02-05", roundsUnlocked[2][5]);

				prefs.putBoolean("round03-01", roundsUnlocked[3][1]);
				prefs.putBoolean("round03-02", roundsUnlocked[3][2]);
				prefs.putBoolean("round03-03", roundsUnlocked[3][3]);
				prefs.putBoolean("round03-04", roundsUnlocked[3][4]);
				prefs.putBoolean("round03-05", roundsUnlocked[3][5]);

				prefs.putBoolean("round04-01", roundsUnlocked[4][1]);
				prefs.putBoolean("round04-02", roundsUnlocked[4][2]);
				prefs.putBoolean("round04-03", roundsUnlocked[4][3]);
				prefs.putBoolean("round04-04", roundsUnlocked[4][4]);
				prefs.putBoolean("round04-05", roundsUnlocked[4][5]);

				prefs.putBoolean("round05-01", roundsUnlocked[5][1]);
				prefs.putBoolean("round05-02", roundsUnlocked[5][2]);
				prefs.putBoolean("round05-03", roundsUnlocked[5][3]);
				prefs.putBoolean("round05-04", roundsUnlocked[5][4]);
				prefs.putBoolean("round05-05", roundsUnlocked[5][5]);

				prefs.putInteger("score01-01", ranks[1][1]);
				prefs.putInteger("score01-02", ranks[1][2]);
				prefs.putInteger("score01-03", ranks[1][3]);
				prefs.putInteger("score01-04", ranks[1][4]);
				prefs.putInteger("score01-05", ranks[1][5]);

				prefs.putInteger("score02-01", ranks[2][1]);
				prefs.putInteger("score02-02", ranks[2][2]);
				prefs.putInteger("score02-03", ranks[2][3]);
				prefs.putInteger("score02-04", ranks[2][4]);
				prefs.putInteger("score02-05", ranks[2][5]);

				prefs.putInteger("score03-01", ranks[3][1]);
				prefs.putInteger("score03-02", ranks[3][2]);
				prefs.putInteger("score03-03", ranks[3][3]);
				prefs.putInteger("score03-04", ranks[3][4]);
				prefs.putInteger("score03-05", ranks[3][5]);

				prefs.putInteger("score04-01", ranks[4][1]);
				prefs.putInteger("score04-02", ranks[4][2]);
				prefs.putInteger("score04-03", ranks[4][3]);
				prefs.putInteger("score04-04", ranks[4][4]);
				prefs.putInteger("score04-05", ranks[4][5]);

				prefs.putInteger("score05-01", ranks[5][1]);
				prefs.putInteger("score05-02", ranks[5][2]);
				prefs.putInteger("score05-03", ranks[5][3]);
				prefs.putInteger("score05-04", ranks[5][4]);
				prefs.putInteger("score05-05", ranks[5][5]);

				prefs.putBoolean("slime-green",
						unlockedViro[SLIME][SLIME_GREEN]);
				prefs.putBoolean("slime-blue", unlockedViro[SLIME][SLIME_BLUE]);
				prefs.putBoolean("slime-orange",
						unlockedViro[SLIME][SLIME_ORANGE]);
				prefs.putBoolean("slime-red", unlockedViro[SLIME][SLIME_RED]);

				prefs.putBoolean("duri-green", unlockedViro[DURI][DURI_GREEN]);
				prefs
						.putBoolean("duri-orange",
								unlockedViro[DURI][DURI_ORANGE]);
				prefs
						.putBoolean("duri-violet",
								unlockedViro[DURI][DURI_VIOLET]);

				prefs.putBoolean("gebuk-green",
						unlockedViro[GEBUK][GEBUK_GREEN]);
				prefs.putBoolean("gebuk-pink", unlockedViro[GEBUK][GEBUK_PINK]);
				prefs.putBoolean("gebuk-red", unlockedViro[GEBUK][GEBUK_RED]);

				prefs.putBoolean("petelur-blue",
						unlockedViro[PETELUR][PETELUR_BLUE]);
				prefs.putBoolean("petelur-violet",
						unlockedViro[PETELUR][PETELUR_VIOLET]);
				prefs.putBoolean("petelur-yellow",
						unlockedViro[PETELUR][PETELUR_YELLOW]);
				
				prefs.putBoolean("black-rbj",
						unlockedViro[BLACK][RBJ]);
				prefs.putBoolean("black-spt",
						unlockedViro[BLACK][SPT]);
				prefs.putBoolean("black-htn",
						unlockedViro[BLACK][HTN]);
				prefs.putBoolean("black-smc",
						unlockedViro[BLACK][SMC]);
				
				
				
			} else {
				
				theEnd =prefs.getBoolean("theend");
				
				modeInvisibleUnlocked = prefs.getBoolean("modeInvis");
				modeBelumTahuUnlocked = prefs.getBoolean("modeBelumtahu");
				modeShieldUnlocked = prefs.getBoolean("modeShield");
				modeImperialUnlocked = prefs.getBoolean("modeImperial");
				
				
				stagesUnlocked = new Boolean[7];
				roundsUnlocked = new Boolean[7][7];
				roundsUnlocked[1] = new Boolean[7];
				roundsUnlocked[2] = new Boolean[7];
				roundsUnlocked[3] = new Boolean[7];
				roundsUnlocked[4] = new Boolean[7];
				roundsUnlocked[5] = new Boolean[7];

				soundEnabled = prefs.getBoolean("soundEnabled");
				
				stagesUnlocked[1] = prefs.getBoolean("stage01");
				stagesUnlocked[2] = prefs.getBoolean("stage02");
				stagesUnlocked[3] = prefs.getBoolean("stage03");
				stagesUnlocked[4] = prefs.getBoolean("stage04");
				stagesUnlocked[5] = prefs.getBoolean("stage05");

				roundsUnlocked[1][1] = prefs.getBoolean("round01-01");
				roundsUnlocked[1][2] = prefs.getBoolean("round01-02");
				roundsUnlocked[1][3] = prefs.getBoolean("round01-03");
				roundsUnlocked[1][4] = prefs.getBoolean("round01-04");
				roundsUnlocked[1][5] = prefs.getBoolean("round01-05");

				roundsUnlocked[2][1] = prefs.getBoolean("round02-01");
				roundsUnlocked[2][2] = prefs.getBoolean("round02-02");
				roundsUnlocked[2][3] = prefs.getBoolean("round02-03");
				roundsUnlocked[2][4] = prefs.getBoolean("round02-04");
				roundsUnlocked[2][5] = prefs.getBoolean("round02-05");

				roundsUnlocked[3][1] = prefs.getBoolean("round03-01");
				roundsUnlocked[3][2] = prefs.getBoolean("round03-02");
				roundsUnlocked[3][3] = prefs.getBoolean("round03-03");
				roundsUnlocked[3][4] = prefs.getBoolean("round03-04");
				roundsUnlocked[3][5] = prefs.getBoolean("round03-05");

				roundsUnlocked[4][1] = prefs.getBoolean("round04-01");
				roundsUnlocked[4][2] = prefs.getBoolean("round04-02");
				roundsUnlocked[4][3] = prefs.getBoolean("round04-03");
				roundsUnlocked[4][4] = prefs.getBoolean("round04-04");
				roundsUnlocked[4][5] = prefs.getBoolean("round04-05");

				roundsUnlocked[5][1] = prefs.getBoolean("round05-01");
				roundsUnlocked[5][2] = prefs.getBoolean("round05-02");
				roundsUnlocked[5][3] = prefs.getBoolean("round05-03");
				roundsUnlocked[5][4] = prefs.getBoolean("round05-04");
				roundsUnlocked[5][5] = prefs.getBoolean("round05-05");

				ranks = new int[7][7];
				ranks[1] = new int[7];
				ranks[2] = new int[7];
				ranks[3] = new int[7];
				ranks[4] = new int[7];
				ranks[5] = new int[7];

				ranks[1][1] = prefs.getInteger("score01-01");
				ranks[1][2] = prefs.getInteger("score01-02");
				ranks[1][3] = prefs.getInteger("score01-03");
				ranks[1][4] = prefs.getInteger("score01-04");
				ranks[1][5] = prefs.getInteger("score01-05");

				ranks[2][1] = prefs.getInteger("score02-01");
				ranks[2][2] = prefs.getInteger("score02-02");
				ranks[2][3] = prefs.getInteger("score02-03");
				ranks[2][4] = prefs.getInteger("score02-04");
				ranks[2][5] = prefs.getInteger("score02-05");

				ranks[3][1] = prefs.getInteger("score03-01");
				ranks[3][2] = prefs.getInteger("score03-02");
				ranks[3][3] = prefs.getInteger("score03-03");
				ranks[3][4] = prefs.getInteger("score03-04");
				ranks[3][5] = prefs.getInteger("score03-05");

				ranks[4][1] = prefs.getInteger("score04-01");
				ranks[4][2] = prefs.getInteger("score04-02");
				ranks[4][3] = prefs.getInteger("score04-03");
				ranks[4][4] = prefs.getInteger("score04-04");
				ranks[4][5] = prefs.getInteger("score04-05");

				ranks[5][1] = prefs.getInteger("score05-01");
				ranks[5][2] = prefs.getInteger("score05-02");
				ranks[5][3] = prefs.getInteger("score05-03");
				ranks[5][4] = prefs.getInteger("score05-04");
				ranks[5][5] = prefs.getInteger("score05-05");

				unlockedViro = new Boolean[7][7];
				unlockedViro[SLIME] = new Boolean[7];
				unlockedViro[DURI] = new Boolean[7];
				unlockedViro[GEBUK] = new Boolean[7];
				unlockedViro[PETELUR] = new Boolean[7];
				unlockedViro[BLACK] = new Boolean[7];

				unlockedViro[SLIME][SLIME_GREEN] = prefs
						.getBoolean("slime-green");
				unlockedViro[SLIME][SLIME_BLUE] = prefs
						.getBoolean("slime-blue");
				unlockedViro[SLIME][SLIME_ORANGE] = prefs
						.getBoolean("slime-orange");
				unlockedViro[SLIME][SLIME_RED] = prefs.getBoolean("slime-red");

				unlockedViro[DURI][DURI_GREEN] = prefs.getBoolean("duri-green");
				unlockedViro[DURI][DURI_VIOLET] = prefs
						.getBoolean("duri-violet");
				unlockedViro[DURI][DURI_ORANGE] = prefs
						.getBoolean("duri-orange");

				unlockedViro[GEBUK][GEBUK_GREEN] = prefs
						.getBoolean("gebuk-green");
				unlockedViro[GEBUK][GEBUK_PINK] = prefs
						.getBoolean("gebuk-pink");
				unlockedViro[GEBUK][GEBUK_RED] = prefs.getBoolean("gebuk-red");

				unlockedViro[PETELUR][PETELUR_BLUE] = prefs
						.getBoolean("petelur-blue");
				unlockedViro[PETELUR][PETELUR_VIOLET] = prefs
						.getBoolean("petelur-violet");
				unlockedViro[PETELUR][PETELUR_YELLOW] = prefs
						.getBoolean("petelur-yellow");
				
				unlockedViro[BLACK][RBJ] = prefs
				.getBoolean("black-rbj");
				unlockedViro[BLACK][SPT] = prefs
				.getBoolean("black-spt");
				unlockedViro[BLACK][HTN] = prefs
				.getBoolean("black-htn");
				unlockedViro[BLACK][SMC] = prefs
				.getBoolean("black-smc");
				
		
			}
			prefs.putBoolean("soundEnabled", soundEnabled);
		} else {
			
		}

	}

	public static void save() {
		prefs = Gdx.app.getPreferences(".Settings");
		if (prefs != null) {
			
			prefs.putBoolean("modeShield", modeShieldUnlocked);
			prefs.putBoolean("modeInvis", modeInvisibleUnlocked);
			prefs.putBoolean("modeImperial", modeImperialUnlocked);
			prefs.putBoolean("modeBelumtahu", modeBelumTahuUnlocked);
			
			prefs.putBoolean("stage01", stagesUnlocked[1]);
			prefs.putBoolean("stage02", stagesUnlocked[2]);
			prefs.putBoolean("stage03", stagesUnlocked[3]);
			prefs.putBoolean("stage04", stagesUnlocked[4]);
			prefs.putBoolean("stage05", stagesUnlocked[5]);

			prefs.putBoolean("round01-01", roundsUnlocked[1][1]);
			prefs.putBoolean("round01-02", roundsUnlocked[1][2]);
			prefs.putBoolean("round01-03", roundsUnlocked[1][3]);
			prefs.putBoolean("round01-04", roundsUnlocked[1][4]);
			prefs.putBoolean("round01-05", roundsUnlocked[1][5]);

			prefs.putBoolean("round02-01", roundsUnlocked[2][1]);
			prefs.putBoolean("round02-02", roundsUnlocked[2][2]);
			prefs.putBoolean("round02-03", roundsUnlocked[2][3]);
			prefs.putBoolean("round02-04", roundsUnlocked[2][4]);
			prefs.putBoolean("round02-05", roundsUnlocked[2][5]);

			prefs.putBoolean("round03-01", roundsUnlocked[3][1]);
			prefs.putBoolean("round03-02", roundsUnlocked[3][2]);
			prefs.putBoolean("round03-03", roundsUnlocked[3][3]);
			prefs.putBoolean("round03-04", roundsUnlocked[3][4]);
			prefs.putBoolean("round03-05", roundsUnlocked[3][5]);

			prefs.putBoolean("round04-01", roundsUnlocked[4][1]);
			prefs.putBoolean("round04-02", roundsUnlocked[4][2]);
			prefs.putBoolean("round04-03", roundsUnlocked[4][3]);
			prefs.putBoolean("round04-04", roundsUnlocked[4][4]);
			prefs.putBoolean("round04-05", roundsUnlocked[4][5]);

			prefs.putBoolean("round05-01", roundsUnlocked[5][1]);
			prefs.putBoolean("round05-02", roundsUnlocked[5][2]);
			prefs.putBoolean("round05-03", roundsUnlocked[5][3]);
			prefs.putBoolean("round05-04", roundsUnlocked[5][4]);
			prefs.putBoolean("round05-05", roundsUnlocked[5][5]);

			prefs.putInteger("score01-01", ranks[1][1]);
			prefs.putInteger("score01-02", ranks[1][2]);
			prefs.putInteger("score01-03", ranks[1][3]);
			prefs.putInteger("score01-04", ranks[1][4]);
			prefs.putInteger("score01-05", ranks[1][5]);

			prefs.putInteger("score02-01", ranks[2][1]);
			prefs.putInteger("score02-02", ranks[2][2]);
			prefs.putInteger("score02-03", ranks[2][3]);
			prefs.putInteger("score02-04", ranks[2][4]);
			prefs.putInteger("score02-05", ranks[2][5]);

			prefs.putInteger("score03-01", ranks[3][1]);
			prefs.putInteger("score03-02", ranks[3][2]);
			prefs.putInteger("score03-03", ranks[3][3]);
			prefs.putInteger("score03-04", ranks[3][4]);
			prefs.putInteger("score03-05", ranks[3][5]);

			prefs.putInteger("score04-01", ranks[4][1]);
			prefs.putInteger("score04-02", ranks[4][2]);
			prefs.putInteger("score04-03", ranks[4][3]);
			prefs.putInteger("score04-04", ranks[4][4]);
			prefs.putInteger("score04-05", ranks[4][5]);

			prefs.putInteger("score05-01", ranks[5][1]);
			prefs.putInteger("score05-02", ranks[5][2]);
			prefs.putInteger("score05-03", ranks[5][3]);
			prefs.putInteger("score05-04", ranks[5][4]);
			prefs.putInteger("score05-05", ranks[5][5]);

			prefs.putBoolean("slime-green", unlockedViro[SLIME][SLIME_GREEN]);
			prefs.putBoolean("slime-blue", unlockedViro[SLIME][SLIME_BLUE]);
			prefs.putBoolean("slime-orange", unlockedViro[SLIME][SLIME_ORANGE]);
			prefs.putBoolean("slime-red", unlockedViro[SLIME][SLIME_RED]);

			prefs.putBoolean("duri-green", unlockedViro[DURI][DURI_GREEN]);
			prefs.putBoolean("duri-orange", unlockedViro[DURI][DURI_ORANGE]);
			prefs.putBoolean("duri-violet", unlockedViro[DURI][DURI_VIOLET]);

			prefs.putBoolean("gebuk-green", unlockedViro[GEBUK][GEBUK_GREEN]);
			prefs.putBoolean("gebuk-pink", unlockedViro[GEBUK][GEBUK_PINK]);
			prefs.putBoolean("gebuk-red", unlockedViro[GEBUK][GEBUK_RED]);
			
			prefs.putBoolean("theend",theEnd);

			prefs.putBoolean("petelur-blue",
					unlockedViro[PETELUR][PETELUR_BLUE]);
			prefs.putBoolean("petelur-violet",
					unlockedViro[PETELUR][PETELUR_VIOLET]);
			prefs.putBoolean("petelur-yellow",
					unlockedViro[PETELUR][PETELUR_YELLOW]);
			
			prefs.putBoolean("black-rbj",
					unlockedViro[BLACK][RBJ]);
			prefs.putBoolean("black-spt",
					unlockedViro[BLACK][SPT]);
			prefs.putBoolean("black-htn",
					unlockedViro[BLACK][HTN]);
			prefs.putBoolean("black-smc",
					unlockedViro[BLACK][SMC]);
		}
	}
	
//	public static void unlockViro(){
//		prefs.putBoolean("slime-green",
//				unlockedViro[SLIME][SLIME_GREEN]);
//		prefs.putBoolean("slime-blue", unlockedViro[SLIME][SLIME_BLUE]);
//		prefs.putBoolean("slime-orange",
//				unlockedViro[SLIME][SLIME_ORANGE]);
//		prefs.putBoolean("slime-red", unlockedViro[SLIME][SLIME_RED]);
//
//		prefs.putBoolean("duri-green", unlockedViro[DURI][DURI_GREEN]);
//		prefs
//				.putBoolean("duri-orange",
//						unlockedViro[DURI][DURI_ORANGE]);
//		prefs
//				.putBoolean("duri-violet",
//						unlockedViro[DURI][DURI_VIOLET]);
//
//		prefs.putBoolean("gebuk-green",
//				unlockedViro[GEBUK][GEBUK_GREEN]);
//		prefs.putBoolean("gebuk-pink", unlockedViro[GEBUK][GEBUK_PINK]);
//		prefs.putBoolean("gebuk-red", unlockedViro[GEBUK][GEBUK_RED]);
//
//		prefs.putBoolean("petelur-blue",
//				unlockedViro[PETELUR][PETELUR_BLUE]);
//		prefs.putBoolean("petelur-violet",
//				unlockedViro[PETELUR][PETELUR_VIOLET]);
//		prefs.putBoolean("petelur-yellow",
//				unlockedViro[PETELUR][PETELUR_YELLOW]);
//		prefs.putBoolean("black-rbj",
//				unlockedViro[BLACK][RBJ]);
//		prefs.putBoolean("black-spt",
//				unlockedViro[BLACK][SPT]);
//		prefs.putBoolean("black-htn",
//				unlockedViro[BLACK][HTN]);
//		prefs.putBoolean("black-smc",
//				unlockedViro[BLACK][SMC]);
//		
//	}

	public static void toggleSound() {
		
		soundEnabled = prefs.getBoolean("soundEnabled");
		if (!soundEnabled) {
			prefs.putBoolean("soundEnabled", true);
			soundEnabled = prefs.getBoolean("soundEnabled");
			Resources.resumeAllMusics();
		} else {
			prefs.putBoolean("soundEnabled", false);
			soundEnabled = prefs.getBoolean("soundEnabled");
			Resources.stopAllMusics();
		}

		// if (!Resources.bgmOpening.isPlaying()){
		// Resources.bgmOpening.play();
		// }else{
		// Resources.bgmOpening.pause();
		//			
		// }

	}

	public static void unlockRound(int stage, int round) {
		roundsUnlocked[stage][round] = true;
		String key = "round0" + stage + "-0" + round;
		prefs.putBoolean(key, roundsUnlocked[stage][round]);
		if (round == 1){
			stagesUnlocked[stage] = true;
			prefs.putBoolean("stage0"+stage, stagesUnlocked[stage]);
		}
	}

	public static void checkRank(int stage, int round, int score) {
		int oldRank = ranks[stage][round];
		if (score > oldRank) {
			ranks[stage][round] = score;
			String key = "score0" + stage + "-0" + round;
			prefs.putInteger(key, ranks[stage][round]);
		}
	}
	
	public static int getResult(){
		load();
		int sum = 0;
		for (int i = 1; i<=5 ; i++){
			for(int j = 1; j<= 5;j++){
				sum = sum + ranks[i][j];
			}
		}
		if (sum == 75){
			return 3;
		}
		else if (sum >=50 && sum <75){
			unlockShieldMode();
			return 2;
		}else
			return 1;
	}
	
	
	public static void unlockShieldMode(){
		if (!prefs.getBoolean("modeShield")){
			prefs.putBoolean("modeShield", true);
			modeShieldUnlocked=true;
		}
	}

	public static void unlockBelumTahuMode(){
		if (!prefs.getBoolean("modeBelumtahu")){
			prefs.putBoolean("modeBelumtahu", true);
			modeBelumTahuUnlocked=true;
		}
	}
	public static void unlockInvisMode(){
		if (!prefs.getBoolean("modeInvis")){
			prefs.putBoolean("modeInvis", true);
			modeInvisibleUnlocked=true;
		}
	}
	public static void unlockImperialMode(){
		if (!prefs.getBoolean("modeImperial")){
			prefs.putBoolean("modeImperial", true);
			modeImperialUnlocked=true;
		}
	}

}
